﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OLMS.DAL;
using OLMS.BLL;

namespace OLMS
{
    public partial class Site : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["user"] != null)
                {
                    Users user = Session["user"] as Users;
                    btnUser.Text = string.Format("<i class='fa fa-user' aria-hidden='true'></i> {0}的订单", user.UserName);
                    btnCart.Text = string.Format("<i class='fa fa-shopping-bag' aria-hidden='true'></i> 购物车（{0}）", CartBLL.GetCount(user.UserId));

                    btnUser.Visible = true;
                    btnCart.Visible = true;
                    btnRegister.Visible = false;
                    btnLogin.Visible = false;
                }
                else
                {
                    btnUser.Visible = false;
                    btnCart.Visible = false;
                    btnRegister.Visible = true;
                    btnLogin.Visible = true;
                }
            }           
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Response.Redirect("Login.aspx");
        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Response.Redirect("Login.aspx?t=reg");
        }

        protected void btnUser_Click(object sender, EventArgs e)
        {
            Response.Redirect("Order.aspx");
        }

        protected void btnCart_Click(object sender, EventArgs e)
        {
            Response.Redirect("Cart.aspx");
        }
    }
}